/**
 * \* Created with IntelliJ IDEA.
 * \* User: 冯若航
 * \* Date: 2021/5/14
 * \* Time: 16:53
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class 两数之和II输入有序数组 {
    public int[] twoSum(int[] numbers, int target) {
        int[]res=new int[2];
        int left=0,right=numbers.length-1;
        while (left<right){
            if(numbers[left]+numbers[right]==target){
                //return new int[]{left+1,right+1};
                res[0]=left+1;
                res[1]=right+1;
                break;
            }else if(numbers[left]+numbers[right]<target){
                left++;
            }else{
                right--;
            }
        }
        return res;
    }
}